package com.example8.rabbitmq_module.controller;

import com.example8.rabbitmq_module.config.RabbitMQConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author lihw
 * @Date 2024/1/23 14:20
 */
@RestController
@RequestMapping("/send")
public class SendController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Autowired
    private RabbitMQConfig rabbitMQConfig;

    @GetMapping("msg")
    public String msg(String value) {

        rabbitTemplate.convertAndSend(rabbitMQConfig.getEXCHANGE(), rabbitMQConfig.getROUTING_KEY(), value);

        return "succ";
    }
}
